import os.path
from openpyxl import load_workbook, Workbook


def create_xlsx_data(file_path, xlsx_header):
    # 文件存在报错
    if os.path.exists(file_path):
        return ValueError(f"{file_path} already exists")
    else:
        # 文件存在 直接给设置表头
        wb = Workbook()
        ws = wb.active
        ws.append(xlsx_header)
        wb.save(file_path)


def xlsx_add_data(file_path, data):
    wb = load_workbook(file_path)
    ws = wb.active
    ws.append(data)
    wb.save(file_path)
    wb.close()
